import { apiGet, apiPost } from "@/request";

/**
 * @description: 获取下一页文章列表
 * @param {string} url 下一页地址
 * @Date: 2023-03-21 00:06:34
 * @Author: mulingyuer
 */
export function getArticleList(url: string) {
	return apiGet<string>({
		url,
		method: "get"
	});
}

/** 点赞返回的结果 */
interface LikeResult {
	code: number;
	msg: string;
	data: any;
}

/**
 * @description: 点赞
 * @param {string} gid
 * @Date: 2023-03-25 03:07:54
 * @Author: mulingyuer
 */
export function postLike(gid: number | string) {
	return apiPost<LikeResult>({
		url: `/index.php?action=addlike`,
		method: "post",
		data: { gid }
	});
}

export function unLike(gid: number | string) {
	return apiPost({
		url: `/?rest-api=unlike`,
		method: "post",
		data: { id: gid }
	});
}

interface Links {
	avatar: string;
	date: string;
	gid: number;
	id: number;
	poster: string;
	uid: number;
}
/** 点赞返回的结果 */
interface LikeListResult {
	code: number;
	msg: string;
	data: { likes: Array<Links> };
}

/**
 * @description: 点赞
 * @param {string} gid
 * @Date: 2023-03-25 03:07:54
 * @Author: mulingyuer
 */
export function getLinks() {
	return apiPost<LikeListResult>({
		url: `/?rest-api=like_list`,
		method: "get",
		params: { id: window.gid }
	});
}
